<template>
	<view>
		<form>
			<!-- <view class="cu-card margin radius">

            <view class="cu-form-group margin-top">
                <view class="title">项目编号</view>
                <view>{{ dataInfo.projectno }}</view>
            </view>
            <view class="cu-form-group ">
                <view class="title">项目名称</view>
                <view>{{ dataInfo.projectname }}</view>
            </view>

          </view> -->
			<xmInfo :projectno="dataInfo.projectno" :projectname="dataInfo.projectname"></xmInfo>
			<view class="cu-form-group " style="margin-top: 10px;">
				<view class="title">地址</view>
				<view><input disabled placeholder="请输入地址" name="input" v-model="dataInfo.caddr" class="input-align"></input>
				</view>
			</view>
			<!-- <view class="cu-form-group ">
                <view class="title">废管说明</view>
                <view><input placeholder="请输入废管说明" name="input" v-model="dataInfo.remarks"  class="input-align"></input></view>
            </view> -->
			<!-- <view class="cu-form-group ">
                <view class="title"><text class="cuIcon-favorfill text-xs text-red"></text
              >试压结果记录</view>
                <view><input placeholder="请输入试压结果记录" name="input" v-model="dataInfo.result"  class="input-align"></input></view>
            </view> -->
			<view class="cu-form-group" style="min-height: 0px;"></view>
			<view class="cu-bar bg-white">
				<view class="action">废管说明</view>
			</view>
			<view class="cu-form-group">
				<textarea disabled maxlength="-1" placeholder="请输入废管说明" v-model="dataInfo.remarks"></textarea>
			</view>
			
			<view class="cu-form-group ">
				<view class="title">废管利旧</view>
				<view>
					<u-checkbox disabled v-model="dataInfo.breuse" ></u-checkbox>
				</view>
			</view>
			
			<!-- @input="textareaAInput" -->
			<view class="cu-form-group" style="min-height: 0px;"></view>
			<view class="cu-bar bg-white">
				<view class="action">废弃通知附件</view>
			</view>
			<view class="cu-form-group ">
				<js-uploadfile v-model="dataInfo.dataMap" uploadType="all" uploadText="请上传文件" :biz-key="dataInfo.id"
				:deletable="false" customBtn="false"	biz-type="PmWastePipeData_notify_file"></js-uploadfile>
			</view>
			<view v-if="dataInfo.breuse == '1'">
				
			
			<!-- <view style="margin: 10px;font-size: 22px;font-weight: bold;color: #3E97B0;">
				废管利旧补充信息
			</view> -->
			<view class="cu-form-group " style="margin-top: 10px;">
				<view style="font-size: 22px;font-weight: bold;color: #3E97B0;">
					废管利旧补充信息
				</view>
			</view>
			<view class="cu-form-group ">
				<view class="title">管道去向</view>
				<view>
					<js-select disabled v-model="dataInfo.dealType"  dict-type="zf_pipe_deal_type"
					disabled	placeholder="请选择管道去向" class="input-align"></js-select>
				</view>
			</view>
			
			<view class="cu-form-group" style="min-height: 0px;"></view>
			<view class="cu-bar bg-white">
				<view class="action">管道规格</view>
			</view>
			<view class="cu-form-group">
				<textarea disabled maxlength="-1" placeholder="请输入管道规格" v-model="dataInfo.pipeDesc"></textarea>
			</view>
			
			<view class="cu-form-group" style="min-height: 0px;"></view>
			<view class="cu-bar bg-white">
				<view class="action">管道利旧备注</view>
			</view>
			<view class="cu-form-group">
				<textarea disabled maxlength="-1" placeholder="请输入管道利旧备注" v-model="dataInfo.dealRemarks"></textarea>
			</view>
			
			<view class="cu-form-group" style="min-height: 0px;"></view>
			<view class="cu-bar bg-white">
				<view class="action">利旧记录表</view>
			</view>
			<view class="cu-form-group ">
				<js-uploadfile v-model="dataInfo.dataMap" uploadType="all" uploadText="请上传文件" :biz-key="dataInfo.id"
				:deletable="false" customBtn="false"	biz-type="PmWastePipeData_reuse_file"></js-uploadfile>
			</view>
			</view>
			<!-- <view style="margin: 10px;font-size: 22px;font-weight: bold;color: #3E97B0;">
				处理结果信息
			</view> -->
			<view class="cu-form-group " style="margin-top: 10px;">
				<view style="font-size: 22px;font-weight: bold;color: #3E97B0;">
					处理结果信息
				</view>
			</view>
			
			<view class="cu-form-group" style="min-height: 0px;"></view>
			<view class="cu-bar bg-white">
				<view class="action">处理结果</view>
			</view>
			<view class="cu-form-group">
				<textarea maxlength="-1" placeholder="请输入处理结果" v-model="dataInfo.dealResult"></textarea>
			</view>
			
			<view class="cu-form-group" style="min-height: 0px;"></view>
			<view class="cu-bar bg-white">
				<view class="action">处理结果附件</view>
			</view>
			<view class="cu-form-group ">
				<js-uploadfile v-model="dataInfo.dataMap" uploadType="all" uploadText="请上传文件" :biz-key="dataInfo.id"
					biz-type="PmWastePipeData_result_file"></js-uploadfile>
			</view>
			
			<!-- <view style="margin: 10px;font-size: 22px;font-weight: bold; color: #3E97B0;">
				申请信息
			</view> -->
			<view class="cu-form-group " style="margin-top: 10px;">
				<view style="font-size: 22px;font-weight: bold;color: #3E97B0;">
					申请信息
				</view>
			</view>
			<view class="cu-form-group " >
				<view class="title">申请人</view>
				<view>{{dataInfo.createByName}}</view>
			</view>
			<view class="cu-form-group " >
				<view class="title">申请时间</view>
				<view>{{dataInfo.createDate}}</view>
			</view>
			<!-- <view class="cu-form-group " >
				<view class="title">地址</view>
				<view><input placeholder="请输入地址" name="input" v-model="dataInfo.caddr" class="input-align"></input>
				</view>
			</view> -->



			<view style="height: 80px"></view>
			<view class="btn-group cu-bar foot ">
				<js-bpm-button v-model="dataInfo.bpm" :biz-key="dataInfo.id" form-key="Flow_WastePipeData"
					@complete="submit"></js-bpm-button>
			</view>
		</form>
		<add-detail :modalNameDetail="modalNameDetail" @modalNameDetailEmit="modalNameDetailEmit"
			v-if="showAddDetail"></add-detail>

	</view>
</template>
<script>
	import xmInfo from "@/pages/zfgs/index/componetns/xmInfo.vue";
	import {hasPermission} from '@/common/fire.js'
	export default {
		components: {
			xmInfo,
		},
		data() {
			return {
				switchA: false,
				date: "2024-03-12",
				uploadOptions: {},
				modalName: null,
				modalNameDetail: null,
				showAddDetail: false,
				dataInfo: {},
				showButton: true,
				isSubmitting: false,
				flag: hasPermission('process:pressure:pmPressuretest:edit'),
			};
		},
		onLoad(e) {
			console.log(e, "e");
			if (!!e.id) {
				console.log(e.id, "e.id");
				this.showButton = true;
				this.getPressurePmPressuretestForm(e.id);
			}
			if (!!e.xm) {
				this.showButton = true;
				this.dataInfo = JSON.parse(e.xm);
				this.dataInfo.status = 4;
				//   巡检人
			}
			// this.dataInfo = JSON.parse(e.item)
		},
		methods: {
			submit() {
				
				if (!this.dataInfo.dealResult) {
					this.$u.toast("处理结果必填");
					return;
				}
				if (
					!this.dataInfo.dataMap ||
					!this.dataInfo.dataMap.PmWastePipeData_result_file
				) {
					this.$u.toast("处理结果附件必传");
					return;
				}
			
					try {
						this.dataInfo.status = 4;
						this.$u.api.zfgs
							.pmWastepipeDatasave(this.dataInfo)
							.then((res) => {
								if (res.result == "true") {
									this.$u.toast(res.message);
									const itemContent = {
										projectno: this.dataInfo.projectno,
										projectname: this.dataInfo.projectname,
									};
									setTimeout(() => {
										// uni.navigateTo({
										//   url:
										//     "/pages/zfgs/process/pressure/pmPressuretest/list?item=" +
										//     JSON.stringify(itemContent),
										// });
										uni.navigateBack({
											delta: 1,
										});
									}, 500);
								} else {
									this.$u.toast(res.message);
								}
							});
					} catch (error) {
						this.$u.toast(error.message);
					} finally {
						this.isSubmitting = false;
					}
			},

			getPressurePmPressuretestForm(id) {
				this.$u.api.zfgs
					.pmWastepipeDataform({
						id: id,
					})
					.then((res) => {
						this.dataInfo = res.pmWastepipeData;
					});
			},
			SwitchA(e) {
				// this.switchA = e.detail.value
			},
			DateChange(e) {
				this.date = e.detail.value;
			},
			textareaAInput(e) {
				this.dataInfo.result = e.detail.value;
			},
			addDetail() {
				this.showAddDetail = true;

				this.modalNameDetail = "bottomModal";

				console.log(this.modalNameDetail);
			},
			modalNameDetailEmit(e) {
				this.modalNameDetail = e;
			},

			ViewImage(imageList, e) {
				uni.previewImage({
					urls: imageList,
					current: e.currentTarget.dataset.url,
				});
			},
			DelImg(e) {
				uni.showModal({
					title: "",
					content: "确定要删除吗？",
					cancelText: "取消",
					confirmText: "确认",
					success: (res) => {
						if (res.confirm) {
							console.log(
								res.confirm,
								this.dataInfo.dImageList,
								e,
								this.dataInfo.dImageList[e.currentTarget.dataset.index]
							);

							this.$delete(
								this.dataInfo.dImageListst,
								e.currentTarget.dataset.index
							);
						}
					},
				});
			},
			ChooseImage() {
				uni.chooseImage({
					count: 4, //默认9
					sizeType: ["original", "compressed"], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ["album"], //从相册选择
					success: (res) => {
						if (this.dataInfo.shiYaFile.length != 0) {
							this.dataInfo.shiYaFile = this.dataInfo.shiYaFile.concat(
								res.tempFilePaths
							);
						} else {
							this.dataInfo.shiYaFile = res.tempFilePaths;
						}

						console.log(this.dataInfo, "this.dataInfo");
						this.$u.toast("上传成功");
					},
				});
			},
		},
	};
</script>
<style lang="scss" scoped>
	.action {
		color: #303133;
	}

	.title {
		flex-shrink: 0;
	}

	.text-sl {
		font-size: 22px !important;
	}

	.cu-bar {}

	.cu-btn {
		font-size: 16px;
		height: 40px;
	}

	.foot {
		min-height: 80px;
		z-index: 997;
		background: #fff;
	}

	.green {
		color: green;
	}

	.input-align {
		text-align: right;
	}

	.text-xs {
		font-size: 18rpx !important;
	}
</style>